<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:panelGrid xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:sijyp="http://java.sun.com/jsf/composite/sijyp"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions" id="formAvaluos"
	style="width:100%">


	<rich:panel style="border:none;" id="formAvaluo">
		<script type="javascript">
addTextAreaCounterByClass();</script>
		<h:panelGrid columns="4" width="100%"
			columnClasses="tenenciaFirstColumn, , , ">
			<ui:include src="/general/topBienesFormsFields.xhtml">
				
				<ui:param name="disabledFechaRegistro"
					value="#{bienAvaluoManager.consultaAvaluo}" />
				<ui:param name="etapaGestionValue"
					value="#{bienManager.bien.tpEtapaGestion.nombre}" />
				<ui:param name="requiredEtapaGestion" value="false" />
				<ui:param name="disabledEtapaGestion" value="true" />
				<ui:param name="prepId" value="avaluos" />
			</ui:include>
		</h:panelGrid>
		<hr width="100%" />
		<br />
		<h:panelGrid columns="6" columnClasses="tenenciaFirstColumn,,,,"
			width="100%">

			<ui:include src="/general/personaField.xhtml">
				<ui:param name="personaNombre"
					value="#{bienAvaluoManager.bienAvaluo.nombreAvaluador}" />
				<ui:param name="idPopupPersona" value="popUpAvaluador" />
				<ui:param name="requiredField" value="true" />
				<ui:param name="fieldLabel"
					value="${msg['bienes.avaluos.avaluador']}" />
				<ui:param name="inputTextClass" value="" />
				<ui:param name="invokerBean" value="#{bienAvaluoManager}" />
				<ui:param name="disabledField"
					value="#{bienAvaluoManager.consultaAvaluo}" />
				<ui:param name="prepId" value="avaluos" />
				<ui:param name="onOpenRenderComponents"
					value=":popUpAvaluadorComponent" />
			</ui:include>

			<h:panelGrid columns="2">
				<h:outputText value="${msg['bienes.avaluos.tipoAvaluo']}" />
				<h:outputText value="*"
					rendered="#{!bienAvaluoManager.consultaAvaluo}" />
			</h:panelGrid>
			<h:panelGrid>
				<h:selectOneMenu id="tipoAvaluo"
					requiredMessage="${msg['general.requerido']}"
					validatorMessage="${msg['general.requerido']}" required="true"
					label="${msg['bienes.avaluos.tipoAvaluo']}"
					value="#{bienAvaluoManager.bienAvaluo.tpAvaluoBean.tpAvaluo}"
					disabled="#{bienAvaluoManager.consultaAvaluo}">
					<f:selectItems value="#{applicationBean.tipoAvaluos}" />
				</h:selectOneMenu>
				<h:message for="tipoAvaluo" errorClass="validationErrorMessage"
					showSummary="false" />
			</h:panelGrid>
			<h:panelGrid columns="2">
				<h:outputLabel value="${msg['bienes.avaluos.fecha']}"
					for="fechaDeAvaluo" />
				<h:outputLabel value="*"
					rendered="#{!bienAvaluoManager.consultaAvaluo}" />
			</h:panelGrid>
			<h:panelGrid>
				<rich:calendar id="fechaDeAvaluo" datePattern="dd/MM/yyyy"
					defaultTime="00:00:00" boundaryDatesMode="hidden" required="true"
					value="#{bienAvaluoManager.bienAvaluo.fchAvaluo}"
					dayDisableFunction="deshabilitarDiaPosterior"
					dayClassFunction="obtenerEstiloDisabled"
					disabled="#{bienAvaluoManager.consultaAvaluo}"
					requiredMessage="${msg['general.requerido']}" />
				<h:message for="fechaDeAvaluo" errorClass="validationErrorMessage"
					showSummary="false" />
			</h:panelGrid>

			<h:panelGrid columns="2">
				<h:outputText value="${msg['bienes.avaluos.valorEstimado']}" />
				<h:outputText value="*"
					rendered="#{!bienAvaluoManager.consultaAvaluo}" />
			</h:panelGrid>
			<h:panelGrid>
				<h:inputText id="valorEstimado" maxlength="150"
					value="#{bienAvaluoManager.bienAvaluo.valor}" styleClass=""
					required="true" requiredMessage="${msg['general.requerido']}"
					disabled="#{bienAvaluoManager.consultaAvaluo}">
					<f:convertNumber type="currency" maxFractionDigits="2"
						currencySymbol="" />
				</h:inputText>
				<h:message for="valorEstimado" errorClass="validationErrorMessage"
					showSummary="false" />
			</h:panelGrid>

			<h:panelGrid columns="2">
				<h:outputText value="${msg['bienes.avaluos.moneda']}" />
				<h:outputText value="*"
					rendered="#{!bienAvaluoManager.consultaAvaluo}" />
			</h:panelGrid>
			<h:panelGrid>
				<h:selectOneMenu id="monedaAvaluo"
					validatorMessage="${msg['general.requerido']}"
					requiredMessage="${msg['general.requerido']}" required="true"
					label="${msg['bienes.avaluos.moneda']}"
					value="#{bienAvaluoManager.bienAvaluo.tpMonedaBean.tpMoneda}"
					disabled="#{bienAvaluoManager.consultaAvaluo}">
					<f:selectItems value="#{applicationBean.tipoMonedas}" />
				</h:selectOneMenu>
				<h:message for="monedaAvaluo" errorClass="validationErrorMessage"
					showSummary="false" />
			</h:panelGrid>

		</h:panelGrid>

		<br />

		<h:panelGrid width="100%" columns="2"
			columnClasses="tenenciaFirstColumn,">
			<h:panelGrid columns="2">
				<h:outputLabel value="${msg['bienes.avaluos.observaciones']}"
					for="observacionesAvaluos" />
				<h:outputText value="*" rendered="false" />
			</h:panelGrid>
			<h:panelGrid width="100%">
				<h:inputTextarea id="observacionesAvaluos" style="width:100%"
					rows="3" styleClass="long count250"
					requiredMessage="${msg['general.requerido']}"
					value="#{bienAvaluoManager.bienAvaluo.observaciones}"
					disabled="#{bienAvaluoManager.consultaAvaluo}">
					<f:validateLength maximum="250" />
				</h:inputTextarea>
				<h:message for="observacionesAvaluos"
					errorClass="validationErrorMessage" showSummary="false" />
			</h:panelGrid>
		</h:panelGrid>

		<h:panelGrid columns="2" columnClasses=",col100" width="100%">
			<h:outputText value="Soporte " />

			<hr width="100%" />
		</h:panelGrid>

		<sijyp:fileUploadSijyp isReading="#{bienAvaluoManager.consultaAvaluo}"
			tiposDocumentos="#{applicationBean.tipoDocumentoAvaluos}"
			bean="#{bienAvaluoManager}" />

		<br />

		<br />

		<h:panelGroup style="text-align:center;" layout="block">
			<h:commandButton value="${msg['boton.adicionar']}"
				action="#{bienAvaluoManager.guardarAvaluo()}"
				rendered="#{!bienAvaluoManager.editaAvaluo and !bienAvaluoManager.consultaAvaluo}">
				<f:ajax render=":formTabs:formAvaluos :sijypMessages"
					execute="@this :formTabs:formAvaluos" />
			</h:commandButton>
			<h:commandButton value="${msg['boton.modificar']}"
				action="#{bienAvaluoManager.modificarAvaluo()}"
				rendered="#{bienAvaluoManager.editaAvaluo and !bienAvaluoManager.consultaAvaluo}">
				<f:ajax render=":formTabs:formAvaluos :sijypMessages"
					execute="@this :formTabs:formAvaluos" />
			</h:commandButton>
			<h:commandButton value="${msg['boton.cancelar']}"
				rendered="#{!bienManager.reading }"
				action="#{bienAvaluoManager.cancelarAccion()}">
				<f:ajax execute="@this"
					render=":formTabs:formAvaluos :sijypMessages" />
			</h:commandButton>
		</h:panelGroup>

		<br />

		<rich:dataTable id="richTable4" var="record_"
			value="#{bienAvaluoManager.bienAvaluosDataModel}" rows="10"
			noDataLabel="${msg['general.registrosNoEncontrados']}"
			style="margin:0 auto; width: 100%;">

			<ui:include src="/resources/sijyp/jpaColumn.xhtml">
				<ui:param name="bean" value="#{bienAvaluoManager}" />
				<ui:param name="propertyTitle"
					value="bienes.resultadoConsultaBienes.tablaBienes.idBien" />
				<ui:param name="explicitProperty" value="#{record_.bien.idBien}" />
				<ui:param name="propertyFilter" value="bien.idBien" />
				<ui:param name="id" value="columnaOculta" />
				<ui:param name="componentRender" value="richTable4" />
				<ui:param name="hideColumn" value="true" />
			</ui:include>
			
			<ui:include src="/resources/sijyp/jpaColumn.xhtml">
				<ui:param name="bean" value="#{bienAvaluoManager}" />
				<ui:param name="propertyTitle" value="bienes.avaluos.etapaDeGestion" />
				<ui:param name="explicitProperty"
					value="#{record_.etapaGestionNombre}" />
				<ui:param name="propertyFilter"
					value="bien.tpEtapaGestion.tpEtapaGestion" />
				<ui:param name="componentRender" value="richTable4" />
				<ui:param name="hideColumn" value="true" />
			</ui:include>
			<ui:include src="/resources/sijyp/jpaColumn.xhtml">
				<ui:param name="bean" value="#{bienAvaluoManager}" />
				<ui:param name="propertyTitle" value="bienes.avaluos.avaluador" />
				<ui:param name="explicitProperty" value="#{record_.nombreAvaluador}" />
				<ui:param name="propertyFilter" value="nombreAvaluador" />
				<ui:param name="componentRender" value="richTable4" />
			</ui:include>
			<ui:include src="/resources/sijyp/jpaColumn.xhtml">
				<ui:param name="bean" value="#{bienAvaluoManager}" />
				<ui:param name="propertyTitle" value="bienes.avaluos.tipoAvaluo" />
				<ui:param name="explicitProperty" value="#{record_.tpAvaluoNombre}" />
				<ui:param name="propertyFilter" value="tpAvaluoBean.nombre" />
				<ui:param name="componentRender" value="richTable4" />
			</ui:include>
			<ui:include src="/resources/sijyp/jpaColumn.xhtml">
				<ui:param name="bean" value="#{bienAvaluoManager}" />
				<ui:param name="propertyTitle" value="bienes.avaluos.fecha" />
				<ui:param name="explicitProperty" value="#{record_.fchAvaluo}" />
				<ui:param name="propertyFilter" value="fchAvaluo" />
				<ui:param name="fecha" value="true" />
				<ui:param name="componentRender" value="richTable4" />
			</ui:include>
			<ui:include src="/resources/sijyp/jpaColumn.xhtml">
				<ui:param name="bean" value="#{bienAvaluoManager}" />
				<ui:param name="propertyTitle" value="bienes.avaluos.valorEstimado" />
				<ui:param name="explicitProperty" value="#{record_.valor}" />
				<ui:param name="propertyFilter" value="valor" />
				<ui:param name="componentRender" value="richTable4" />
				<ui:param name="currency" value="true" />
				<ui:param name="explicitPropertyCurrencyType"
					value="#{record_.tpMonedaBean.tpMoneda}" />
			</ui:include>
			<ui:include src="/resources/sijyp/jpaColumn.xhtml">
				<ui:param name="bean" value="#{bienAvaluoManager}" />
				<ui:param name="propertyTitle"
					value="bienes.fileUpload.tipoDocumento" />
				<ui:param name="explicitProperty"
					value="#{record_.tipoDocumentoNombre}" />
				<ui:param name="propertyFilter" value="bienDocumento.tipoDocumento" />
				<ui:param name="componentRender" value="richTable4" />
			</ui:include>
			<ui:include src="/resources/sijyp/jpaColumn.xhtml">
				<ui:param name="bean" value="#{bienAvaluoManager}" />
				<ui:param name="propertyTitle" value="bienes.avaluos.archivo" />
				<ui:param name="explicitProperty" value="#{record_.archivoNombre}" />
				<ui:param name="propertyFilter" value="bienDocumento.nombre" />
				<ui:param name="link" value="true" />
				<ui:param name="record" value="#{record_.bienDocumento}" />
				<ui:param name="componentRender" value="richTable4" />
			</ui:include>
			<rich:column>
				<f:facet name="header">
					<sijyp:sortTable title="${msg['general.tabla.accion']}"></sijyp:sortTable>
				</f:facet>
				<h:panelGrid columns="3"
					columnClasses="icon_space,icon_space,icon_space,icon_space,icon_space">

					<h:commandLink value=""
						action="#{bienAvaluoManager.editarAvaluo()}"
						rendered="#{!bienAvaluoManager.consultaAvaluo and !bienManager.disableSubtabsDeleteAction}">
						<h:graphicImage value="/resources/images/icons/ico_pencil.png"
							title="${msg['boton.editar']}" />
						<f:setPropertyActionListener
							target="#{bienAvaluoManager.avaluoTemporal}" value="#{record_}" />
						<f:ajax execute="@this"
							render=":formTabs:formAvaluos :sijypMessages" />
					</h:commandLink>

					<ui:remove>Gray edit action icon</ui:remove>
					<h:graphicImage value="/resources/images/icons/ico_pencil_gray.png"
						title="${msg['boton.editar']}"
						rendered="#{bienManager.disableSubtabsDeleteAction}" />

					<h:commandLink value=""
						action="#{bienAvaluoManager.consultarAvaluo()}">
						<h:graphicImage value="/resources/images/icons/ico_details.png"
							title="${msg['boton.consultar']}" />
						<f:setPropertyActionListener
							target="#{bienAvaluoManager.avaluoTemporal}" value="#{record_}" />
						<f:ajax execute="@this"
							render=":formTabs:formAvaluos :sijypMessages" />
					</h:commandLink>

					<a4j:commandLink value="" execute="@this" render="@none"
						rendered="#{!bienAvaluoManager.consultaAvaluo and !bienManager.disableSubtabsDeleteAction}"
						oncomplete="#{rich:component('confirmDeleteAvaluo')}.show()">
						<h:graphicImage value="/resources/images/icons/ico_delete.png"
							title="${msg['boton.eliminar']}" />
						<a4j:param value="#{record_.idBienAvaluo}"
							assignTo="#{bienAvaluoManager.bienAvaluoIdDelete}" />
					</a4j:commandLink>

					<ui:remove>Gray delete action icon</ui:remove>
					<h:graphicImage
						value="/resources/images/icons/ico_delete_disabled.png"
						title="${msg['boton.eliminar']}"
						rendered="#{bienManager.disableSubtabsDeleteAction}" />
				</h:panelGrid>
			</rich:column>
			<f:facet name="footer">
				<rich:dataScroller maxPages="10" fastStep="5" fastControls="hide" stepControls="show" />
			</f:facet>
		</rich:dataTable>

		<br />

		<sijyp:confirmDialog message="${msg['general.confirmaBorrar']}"
			confirmId="confirmDeleteAvaluo"
			renderComponents=":formTabs:formAvaluos @this :sijypMessages"
			acceptAction="#{bienAvaluoManager.eliminarAvaluo}" />
	</rich:panel>

</h:panelGrid>
